package services

import (
	"github.com/mlogclub/simple/sqls"
	"github.com/mlogclub/simple/web/params"

	"bbs-go/internal/models"
	"bbs-go/internal/repositories"
)

var ApprovalProcessService = newApprovalProcessService()

func newApprovalProcessService() *approvalProcessService {
	return &approvalProcessService{}
}

type approvalProcessService struct {
}

func (s *approvalProcessService) Get(id int64) *models.ApprovalProcess {
	return repositories.ApprovalProcessRepository.Get(sqls.DB(), id)
}

func (s *approvalProcessService) Take(where ...interface{}) *models.ApprovalProcess {
	return repositories.ApprovalProcessRepository.Take(sqls.DB(), where...)
}

func (s *approvalProcessService) Find(cnd *sqls.Cnd) []models.ApprovalProcess {
	return repositories.ApprovalProcessRepository.Find(sqls.DB(), cnd)
}

func (s *approvalProcessService) FindPageByParams(params *params.QueryParams) (list []models.ApprovalProcess, paging *sqls.Paging) {
	return repositories.ApprovalProcessRepository.FindPageByParams(sqls.DB(), params)
}

func (s *approvalProcessService) FindPageByCnd(cnd *sqls.Cnd) (list []models.ApprovalProcess, paging *sqls.Paging) {
	return repositories.ApprovalProcessRepository.FindPageByCnd(sqls.DB(), cnd)
}

func (s *approvalProcessService) Create(t *models.ApprovalProcess) error {
	return repositories.ApprovalProcessRepository.Create(sqls.DB(), t)
}

func (s *approvalProcessService) Update(t *models.ApprovalProcess) error {
	return repositories.ApprovalProcessRepository.Update(sqls.DB(), t)
}

func (s *approvalProcessService) Updates(id int64, columns map[string]interface{}) error {
	return repositories.ApprovalProcessRepository.Updates(sqls.DB(), id, columns)
}

func (s *approvalProcessService) UpdateColumn(id int64, name string, value interface{}) error {
	return repositories.ApprovalProcessRepository.UpdateColumn(sqls.DB(), id, name, value)
}
